import consts from './consts.js'
import moment from 'moment'

const formaterStatus = (value) => {
  value = value
  return consts.Status[value] || '未知'
}

const formaterSupplierStatus = (value) => {
  value = value
  return consts.SupplierStatus[value] || '未知'
}

const formatDate = (date) => {
  return moment(new Date(date)).format("YYYY-MM-DD") || ' '
}

const formaterGoodsType = (value) => {
  return consts.GoodsType[value] || '未知'
}

const formaterOrderStatus = (value) => {
  return consts.orderStatus[value] || '未知'
}
const formaterAfterSaleType = (value) => {
  return consts.afterSaleType[value] || '未知'
}

const formaterGoodsStatus = (value) => {
  return consts.GoodsStatus[value] || '未知'
}
const formaterAuditStatus = (value) => {
  return consts.AuditStatus[value] || '未知'
}
const formaterBackStatus = (value) => {
  return consts.BackStatus[value] || '未知'
}

const formatTime = (value) => {
  var date = new Date(value)
  var Y = date.getFullYear()
  var M = date.getMonth() + 1
  M = M < 10 ? '0' + M : M
  var d = date.getDate()
  d = d < 10 ? '0' + d : d
  var h = date.getHours()
  h = h < 10 ? '0' + h : h
  var m = date.getMinutes()
  m = m < 10 ? '0' + m : m
  var s = date.getSeconds()
  s = s < 10 ? '0' + s : s
  return Y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s
}

const formaterSettleType = (value) => {
  return consts.settleType[value] || '未知'
}

const formaterAfterSaleFlag = (value) => {
  return consts.afterSaleFlag[value] || '未知'
}



export default {
  formaterStatus,
  formaterSupplierStatus,
  formatDate,
  formaterGoodsType,
  formaterOrderStatus,
  formaterGoodsStatus,
  formaterAfterSaleType,
  formaterAuditStatus,
  formaterBackStatus,
  formatTime,
  formaterSettleType,
  formaterAfterSaleFlag
}
